<template>
    <section>
        <sy-baselist
                ref="conscost"
                editVue="./business/ConstructionCost_Edit.vue"
                :filters="filters"
                listUrl="server/business/ConstructionCost.ashx?cmd=GetList"
                deleteUrl="server/business/ConstructionCost.ashx?cmd=Delete"
                @onLoadRow="onLoadRow"
                :fixWhere="fixWhere"
                :ApproveID="5"
                :hideAdd="hideAdd"
        >
            <el-table-column prop="FNo" label="编号" width="130">
            </el-table-column>
            <el-table-column prop="ProjectName" align="center"  header-align="center" label="项目名称"  width="180" >
            </el-table-column>
            <el-table-column prop="TeamName" align="center"  header-align="center" label="施工队"  width="180" >
            </el-table-column>
            <el-table-column prop="FApplyDate" align="center"  header-align="center" label="申请时间"  width="120" >
            </el-table-column>
            <el-table-column prop="FNeedCost" label="应付款" width="80">
            </el-table-column>
            <el-table-column prop="FAccountCost" label="已付款" width="80">
            </el-table-column>
            <el-table-column prop="StatusName" label="状态" width="100">
            </el-table-column>
            <template  slot="extendbtn_end" scope="props">
                <el-button size="small" v-if="!props.row.hidePrint"  @click="Print(props.row)">打印申请单</el-button>
            </template>
        </sy-baselist>
    </section>
</template>

<script>
    import util from '../../common/util'
    export default {
        data(){
            return {
                dvApprove:false,
                fixWhere:'',
                filters:[],
                hideAdd:false
            }
        },
        methods:{
            onLoadRow(row)
            {
                row.FApplyDate = util.date.format(row.FApplyDate,'yyyy-MM-dd')
                switch(row.FApproveStatus)
                {
                    case 0: row.StatusName="未提交" ; break;
                    case 1: row.StatusName="待审批" ; break;
                    case 3: row.StatusName="审批完成" ; break;
                    case -2: row.StatusName="审批退回" ; break;
                    default: row.StatusName='未知'
                }
                if(row.FApproveStatus!=0&&row.FApproveStatus!=-1){
                    row.hideDeleteBtn=true;
                    row.hideEditBtn=true;
                    if((row.FToApprover!=global.user.FID)||row.FApproveStatus==3)
                    {
                        row.ApproveTitle="查看"
                    }
                    else
                    {
                        row.ApproveTitle= "审核"
                    }
                }
                if(row.FApproveStatus==0||row.FApproveStatus==-1) {
                    row.ApproveTitle= "提交审核"
                }
                if(row.FApproveStatus!=3)
                {
                    row.hidePrint=true;
                }
            },
            init(){
                if(global.nowPath=="/constructioncost-0")
                {
                    this.fixWhere='FApproveStatus in (0,-2)'
                    this.hideAdd=true
                }else if(global.nowPath=="/constructioncost-1"){
                    this.fixWhere='FApproveStatus in (1)'
                    this.hideAdd=true
                }else if(global.nowPath=="/constructioncost-2"){
                    this.fixWhere='FApproveStatus in (3)'
                    this.hideAdd=true
                }else {
                    this.fixWhere=''
                    this.hideAdd=false
                }
                this.filters=[{type: "string",name:"FNo",text:"编号", value: ""},
                    {type: "date",name:"FApplyDate",text:"申请时间", value: null},
                    {type: "string",name:"ProjectName",text:"项目名称", value: ""},
                    {type: "string",name:"TeamName",text:"施工队", value: ""}]
                if(this.fixWhere){

                }else{
                    this.filters.push(
                        {type: "select",name:"FApproveStatus",text:"状态", data:[[0,"未提交"],
                            [2,"待审批"],[3,"审批完成"],[-2,"审批退回"]],value:null})
                }
            },
            Print(row){
                window.open(global.serverHost+"client/print/printConstructionCost.html?FID="+row.FID);
            }
        },
        watch: {
            '$route' (to, from) {
                // 对路由变化作出响应...
                this.init()
            }
        },
        created(){
            this.init()
       }
    }
</script>